home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_006 / microemacs / main.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  24KB  |  597 lines

  1. /*
  2.  * This program is in public domain; written by Dave G. Conroy.
  3.  * This file contains the main driving routine, and some keyboard processing
  4.  * code, for the MicroEMACS screen editor.
  5.  *
  6.  * REVISION HISTORY:
  7.  *
  8.  * 1.0  Steve Wilhite, 30-Nov-85
  9.  *      - Removed the old LK201 and VT100 logic. Added code to support the
  10.  *        DEC Rainbow keyboard (which is a LK201 layout) using the the Level
  11.  *        1 Console In ROM INT. See "rainbow.h" for the function key definitions.
  12.  *
  13.  * 2.0  George Jones, 12-Dec-85
  14.  *      - Ported to Amiga.
  15.  */
  16. #include        <stdio.h>
  17. #include        "ed.h"
  18.  
  19. #if     VMS
  20. #include        <ssdef.h>
  21. #define GOOD    (SS$_NORMAL)
  22. #endif
  23.  
  24. #ifndef GOOD
  25. #define GOOD    0
  26. #endif
  27.  
  28. int     currow;                         /* Working cursor row           */
  29. int     curcol;                         /* Working cursor column        */
  30. int     fillcol;                        /* Current fill column          */
  31. int     thisflag;                       /* Flags, this command          */
  32. int     lastflag;                       /* Flags, last command          */
  33. int     curgoal;                        /* Goal column                  */
  34. BUFFER  *curbp;                         /* Current buffer               */
  35. WINDOW  *curwp;                         /* Current window               */
  36. BUFFER  *bheadp;                        /* BUFFER listhead              */
  37. WINDOW  *wheadp;                        /* WINDOW listhead              */
  38. BUFFER  *blistp;                        /* Buffer list BUFFER           */
  39. short   kbdm[NKBDM] = {CTLX|')'};       /* Macro                        */
  40. short   *kbdmip;                        /* Input  for above             */
  41. short   *kbdmop;                        /* Output for above             */
  42. char    pat[NPAT];                      /* Pattern                      */
  43.  
  44. typedef struct  {
  45.         short   k_code;                 /* Key code                     */
  46.         int     (*k_fp)();              /* Routine to handle it         */
  47. }       KEYTAB;
  48.  
  49. extern  int     ctrlg();                /* Abort out of things          */
  50. extern  int     quit();                 /* Quit                         */
  51. extern  int     ctlxlp();               /* Begin macro                  */
  52. extern  int     ctlxrp();               /* End macro                    */
  53. extern  int     ctlxe();                /* Execute macro                */
  54. extern  int     fileread();             /* Get a file, read only        */
  55. extern  int     filevisit();            /* Get a file, read write       */
  56. extern  int     filewrite();            /* Write a file                 */
  57. extern  int     filesave();             /* Save current file            */
  58. extern  int     filename();             /* Adjust file name             */
  59. extern  int     getccol();              /* Get current column           */
  60. extern  int     gotobol();              /* Move to start of line        */
  61. extern  int     forwchar();             /* Move forward by characters   */
  62. extern  int     gotoeol();              /* Move to end of line          */
  63. extern  int     backchar();             /* Move backward by characters  */
  64. extern  int     forwline();             /* Move forward by lines        */
  65. extern  int     backline();             /* Move backward by lines       */
  66. extern  int     forwpage();             /* Move forward by pages        */
  67. extern  int     backpage();             /* Move backward by pages       */
  68. extern  int     gotobob();              /* Move to start of buffer      */
  69. extern  int     gotoeob();              /* Move to end of buffer        */
  70. extern  int     setfillcol();           /* Set fill column.             */
  71. extern  int     setmark();              /* Set mark                     */
  72. extern  int     swapmark();             /* Swap "." and mark            */
  73. extern  int     forwsearch();           /* Search forward               */
  74. extern  int     backsearch();           /* Search backwards             */
  75. extern  int     showcpos();             /* Show the cursor position     */
  76. extern  int     nextwind();             /* Move to the next window      */
  77. extern  int     prevwind();             /* Move to the previous window  */
  78. extern  int     onlywind();             /* Make current window only one */
  79. extern  int     splitwind();            /* Split current window         */
  80. extern  int     mvdnwind();             /* Move window down             */
  81. extern  int     mvupwind();             /* Move window up               */
  82. extern  int     enlargewind();          /* Enlarge display window.      */
  83. extern  int     shrinkwind();           /* Shrink window.               */
  84. extern  int     listbuffers();          /* Display list of buffers      */
  85. extern  int     usebuffer();            /* Switch a window to a buffer  */
  86. extern  int     killbuffer();           /* Make a buffer go away.       */
  87. extern  int     reposition();           /* Reposition window            */
  88. extern  int     refresh();              /* Refresh the screen           */
  89. extern  int     twiddle();              /* Twiddle characters           */
  90. extern  int     tab();                  /* Insert tab                   */
  91. extern  int     newline();              /* Insert CR-LF                 */
  92. extern  int     indent();               /* Insert CR-LF, then indent    */
  93. extern  int     openline();             /* Open up a blank line         */
  94. extern  int     deblank();              /* Delete blank lines           */
  95. extern  int     quote();                /* Insert literal               */
  96. extern  int     backword();             /* Backup by words              */
  97. extern  int     forwword();             /* Advance by words             */
  98. extern  int     forwdel();              /* Forward delete               */
  99. extern  int     backdel();              /* Backward delete              */
  100. extern  int     kill();                 /* Kill forward                 */
  101. extern  int     yank();                 /* Yank back from killbuffer.   */
  102. extern  int     upperword();            /* Upper case word.             */
  103. extern  int     lowerword();            /* Lower case word.             */
  104. extern  int     upperregion();          /* Upper case region.           */
  105. extern  int     lowerregion();          /* Lower case region.           */
  106. extern  int     capword();              /* Initial capitalize word.     */
  107. extern  int     delfword();             /* Delete forward word.         */
  108. extern  int     delbword();             /* Delete backward word.        */
  109. extern  int     killregion();           /* Kill region.                 */
  110. extern  int     copyregion();           /* Copy region to kill buffer.  */
  111. extern  int     spawncli();             /* Run CLI in a subjob.         */
  112. extern  int     spawn();                /* Run a command in a subjob.   */
  113. extern  int     quickexit();            /* low keystroke style exit.    */
  114.  
  115. /*
  116.  * Command table.
  117.  * This table  is *roughly* in ASCII order, left to right across the
  118.  * characters of the command. This expains the funny location of the
  119.  * control-X commands.
  120.  */
  121. KEYTAB  keytab[] = {
  122.         CTRL|'@',               &setmark,
  123.         CTRL|'A',               &gotobol,
  124.         CTRL|'B',               &backchar,
  125.         CTRL|'C',               &spawncli,      /* Run CLI in subjob.   */
  126.         CTRL|'D',               &forwdel,
  127.         CTRL|'E',               &gotoeol,
  128.         CTRL|'F',               &forwchar,
  129.         CTRL|'G',               &ctrlg,
  130.         CTRL|'H',               &backdel,
  131.         CTRL|'I',               &tab,
  132.         CTRL|'J',               &indent,
  133.         CTRL|'K',               &kill,
  134.         CTRL|'L',               &refresh,
  135.         CTRL|'M',               &newline,
  136.         CTRL|'N',               &forwline,
  137.         CTRL|'O',               &openline,
  138.         CTRL|'P',               &backline,
  139.         CTRL|'Q',               "e,         /* Often unreachable    */
  140.         CTRL|'R',               &backsearch,
  141.         CTRL|'S',               &forwsearch,    /* Often unreachable    */
  142.         CTRL|'T',               &twiddle,
  143.         CTRL|'V',               &forwpage,
  144.         CTRL|'W',               &killregion,
  145.         CTRL|'Y',               &yank,
  146.         CTRL|'Z',               &quickexit,     /* quick save and exit  */
  147.         CTLX|CTRL|'B',          &listbuffers,
  148.         CTLX|CTRL|'C',          &quit,          /* Hard quit.           */
  149.         CTLX|CTRL|'F',          &filename,
  150.         CTLX|CTRL|'L',          &lowerregion,
  151.         CTLX|CTRL|'O',          &deblank,
  152.         CTLX|CTRL|'N',          &mvdnwind,
  153.         CTLX|CTRL|'P',          &mvupwind,
  154.         CTLX|CTRL|'R',          &fileread,
  155.         CTLX|CTRL|'S',          &filesave,      /* Often unreachable    */
  156.         CTLX|CTRL|'U',          &upperregion,
  157.         CTLX|CTRL|'V',          &filevisit,
  158.         CTLX|CTRL|'W',          &filewrite,
  159.         CTLX|CTRL|'X',          &swapmark,
  160.         CTLX|CTRL|'Z',          &shrinkwind,
  161.         CTLX|'!',               &spawn,         /* Run 1 command.       */
  162.         CTLX|'=',               &showcpos,
  163.         CTLX|'(',               &ctlxlp,
  164.         CTLX|')',               &ctlxrp,
  165.         CTLX|'1',               &onlywind,
  166.         CTLX|'2',               &splitwind,
  167.         CTLX|'B',               &usebuffer,
  168.         CTLX|'E',               &ctlxe,
  169.         CTLX|'F',               &setfillcol,
  170.         CTLX|'K',               &killbuffer,
  171.         CTLX|'N',               &nextwind,
  172.         CTLX|'P',               &prevwind,
  173.         CTLX|'Z',               &enlargewind,
  174.         META|CTRL|'H',          &delbword,
  175.         META|'!',               &reposition,
  176.         META|'.',               &setmark,
  177.         META|'>',               &gotoeob,
  178.         META|'<',               &gotobob,
  179.         META|'B',               &backword,
  180.         META|'C',               &capword,
  181.         META|'D',               &delfword,
  182.         META|'F',               &forwword,
  183.         META|'L',               &lowerword,
  184.         META|'U',               &upperword,
  185.         META|'V',               &backpage,
  186.         META|'W',               ©region,
  187.         META|0x7F,              &delbword,
  188.         0x7F,                   &backdel
  189. };
  190.  
  191. #define NKEYTAB (sizeof(keytab)/sizeof(keytab[0]))
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. #if RAINBOW
  201.  
  202. #include "rainbow.h"
  203.  
  204. /*
  205.  * Mapping table from the LK201 function keys to the internal EMACS character.
  206.  */
  207.  
  208. short lk_map[][2] = {
  209.         Up_Key,                         CTRL+'P',
  210.         Down_Key,                       CTRL+'N',
  211.         Left_Key,                       CTRL+'B',
  212.         Right_Key,                      CTRL+'F',
  213.         Shift+Left_Key,                 META+'B',
  214.         Shift+Right_Key,                META+'F',
  215.         Control+Left_Key,               CTRL+'A',
  216.         Control+Right_Key,              CTRL+'E',
  217.         Prev_Scr_Key,                   META+'V',
  218.         Next_Scr_Key,                   CTRL+'V',
  219.         Shift+Up_Key,                   META+'<',
  220.         Shift+Down_Key,                 META+'>',
  221.         Cancel_Key,                     CTRL+'G',
  222.         Find_Key,                       CTRL+'S',
  223.         Shift+Find_Key,                 CTRL+'R',
  224.         Insert_Key,                     CTRL+'Y',
  225.         Options_Key,                    CTRL+'D',
  226.         Shift+Options_Key,              META+'D',
  227.         Remove_Key,                     CTRL+'W',
  228.         Shift+Remove_Key,               META+'W',
  229.         Select_Key,                     CTRL+'@',
  230.         Shift+Select_Key,               CTLX+CTRL+'X',
  231.         Interrupt_Key,                  CTRL+'U',
  232.         Keypad_PF2,                     META+'L',
  233.         Keypad_PF3,                     META+'C',
  234.         Keypad_PF4,                     META+'U',
  235.         Shift+Keypad_PF2,               CTLX+CTRL+'L',
  236.         Shift+Keypad_PF4,               CTLX+CTRL+'U',
  237.         Keypad_1,                       CTLX+'1',
  238.         Keypad_2,                       CTLX+'2',
  239.         Do_Key,                         CTLX+'E',
  240.         Keypad_4,                       CTLX+CTRL+'B',
  241.         Keypad_5,                       CTLX+'B',
  242.         Keypad_6,                       CTLX+'K',
  243.         Resume_Key,                     META+'!',
  244.         Control+Next_Scr_Key,           CTLX+'N',
  245.         Control+Prev_Scr_Key,           CTLX+'P',
  246.         Control+Up_Key,                 CTLX+CTRL+'P',
  247.         Control+Down_Key,               CTLX+CTRL+'N',
  248.         Help_Key,                       CTLX+'=',
  249.         Shift+Do_Key,                   CTLX+'(',
  250.         Control+Do_Key,                 CTLX+')',
  251.         Keypad_0,                       CTLX+'Z',
  252.         Shift+Keypad_0,                 CTLX+CTRL+'Z',
  253.         Main_Scr_Key,                   CTRL+'C',
  254.         Keypad_Enter,                   CTLX+'!',
  255.         Exit_Key,                       CTLX+CTRL+'C',
  256.         Shift+Exit_Key,                 CTRL+'Z'
  257.         };
  258.  
  259. #define lk_map_size     (sizeof(lk_map)/2)
  260.  
  261. #endif
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270. main(argc, argv)
  271. char    *argv[];
  272. {
  273.         register int    c;
  274.         register int    f;
  275.         register int    n;
  276.         register int    mflag;
  277.         char            bname[NBUFN];
  278.  
  279.         strcpy(bname, "main");                  /* Work out the name of */
  280.         if (argc > 1)                           /* the default buffer.  */
  281.                 makename(bname, argv[1]);
  282.         edinit(bname);                          /* Buffers, windows.    */
  283.         vtinit();                               /* Displays.            */
  284.         if (argc > 1) {
  285.                 update();                       /* You have to update   */
  286.                 readin(argv[1]);                /* in case "[New file]" */
  287.         }
  288.         lastflag = 0;                           /* Fake last flags.     */
  289. loop:
  290.         update();                               /* Fix up the screen    */
  291.         c = getkey();
  292.         if (mpresf != FALSE) {
  293.                 mlerase();
  294.                 update();
  295.                 if (c == ' ')                   /* ITS EMACS does this  */
  296.                         goto loop;
  297.         }
  298.         f = FALSE;
  299.         n = 1;
  300.         if (c == (CTRL|'U')) {                  /* ^U, start argument   */
  301.                 f = TRUE;
  302.                 n = 4;                          /* with argument of 4 */
  303.                 mflag = 0;                      /* that can be discarded. */
  304.                 mlwrite("Arg: 4");
  305.                 while ((c=getkey()) >='0' && c<='9' || c==(CTRL|'U') || c=='-'){
  306.                         if (c == (CTRL|'U'))
  307.                                 n = n*4;
  308.                         /*
  309.                          * If dash, and start of argument string, set arg.
  310.                          * to -1.  Otherwise, insert it.
  311.                          */
  312.                         else if (c == '-') {
  313.                                 if (mflag)
  314.                                         break;
  315.                                 n = 0;
  316.                                 mflag = -1;
  317.                         }
  318.                         /*
  319.                          * If first digit entered, replace previous argument
  320.                          * with digit and set sign.  Otherwise, append to arg.
  321.                          */
  322.                         else {
  323.                                 if (!mflag) {
  324.                                         n = 0;
  325.                                         mflag = 1;
  326.                                 }
  327.                                 n = 10*n + c - '0';
  328.                         }
  329.                         mlwrite("Arg: %d", (mflag >=0) ? n : (n ? -n : -1));
  330.                 }
  331.                 /*
  332.                  * Make arguments preceded by a minus sign negative and change
  333.                  * the special argument "^U -" to an effective "^U -1".
  334.                  */
  335.                 if (mflag == -1) {
  336.                         if (n == 0)
  337.                                 n++;
  338.                         n = -n;
  339.                 }
  340.         }
  341.         if (c == (CTRL|'X'))                    /* ^X is a prefix       */
  342.                 c = CTLX | getctl();
  343.         if (kbdmip != NULL) {                   /* Save macro strokes.  */
  344.                 if (c!=(CTLX|')') && kbdmip>&kbdm[NKBDM-6]) {
  345.                         ctrlg(FALSE, 0);
  346.                         goto loop;
  347.                 }
  348.                 if (f != FALSE) {
  349.                         *kbdmip++ = (CTRL|'U');
  350.                         *kbdmip++ = n;
  351.                 }
  352.                 *kbdmip++ = c;
  353.         }
  354.         execute(c, f, n);                       /* Do it.               */
  355.         goto loop;
  356. }
  357.  
  358. /*
  359.  * Initialize all of the buffers and windows. The buffer name is passed down
  360.  * as an argument, because the main routine may have been told to read in a
  361.  * file by default, and we want the buffer name to be right.
  362.  */
  363. edinit(bname)
  364. char    bname[];
  365. {
  366.         register BUFFER *bp;
  367.         register WINDOW *wp;
  368.  
  369.         bp = bfind(bname, TRUE, 0);             /* First buffer         */
  370.         blistp = bfind("[List]", TRUE, BFTEMP); /* Buffer list buffer   */
  371.         wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window         */
  372.         if (bp==NULL || wp==NULL || blistp==NULL)
  373.                 exit(1);
  374.         curbp  = bp;                            /* Make this current    */
  375.         wheadp = wp;
  376.         curwp  = wp;
  377.         wp->w_wndp  = NULL;                     /* Initialize window    */
  378.         wp->w_bufp  = bp;
  379.         bp->b_nwnd  = 1;                        /* Displayed.           */
  380.         wp->w_linep = bp->b_linep;
  381.         wp->w_dotp  = bp->b_linep;
  382.         wp->w_doto  = 0;
  383.         wp->w_markp = NULL;
  384.         wp->w_marko = 0;
  385.         wp->w_toprow = 0;
  386.         wp->w_ntrows = term.t_nrow-1;           /* "-1" for mode line.  */
  387.         wp->w_force = 0;
  388.         wp->w_flag  = WFMODE|WFHARD;            /* Full.                */
  389. }
  390.         
  391. /*
  392.  * This is the general command execution routine. It handles the fake binding
  393.  * of all the keys to "self-insert". It also clears out the "thisflag" word,
  394.  * and arranges to move it to the "lastflag", so that the next command can
  395.  * look at it. Return the status of command.
  396.  */
  397. execute(c, f, n)
  398. {
  399.         register KEYTAB *ktp;
  400.         register int    status;
  401.  
  402.         ktp = &keytab[0];                       /* Look in key table.   */
  403.         while (ktp < &keytab[NKEYTAB]) {
  404.                 if (ktp->k_code == c) {
  405.                         thisflag = 0;
  406.                         status   = (*ktp->k_fp)(f, n);
  407.                         lastflag = thisflag;
  408.                         return (status);
  409.                 }
  410.                 ++ktp;
  411.         }
  412.  
  413.         /*
  414.          * If a space was typed, fill column is defined, the argument is non-
  415.          * negative, and we are now past fill column, perform word wrap.
  416.          */
  417.         if (c == ' ' && fillcol > 0 && n>=0 && getccol(FALSE) > fillcol)
  418.                 wrapword();
  419.  
  420.         if ((c>=0x20 && c<=0x7E)                /* Self inserting.      */
  421.         ||  (c>=0xA0 && c<=0xFE)) {
  422.                 if (n <= 0) {                   /* Fenceposts.          */
  423.                         lastflag = 0;
  424.                         return (n<0 ? FALSE : TRUE);
  425.                 }
  426.                 thisflag = 0;                   /* For the future.      */
  427.                 status   = linsert(n, c);
  428.                 lastflag = thisflag;
  429.                 return (status);
  430.         }
  431.         lastflag = 0;                           /* Fake last flags.     */
  432.         return (FALSE);
  433. }
  434.  
  435. /*
  436.  * Read in a key.
  437.  * Do the standard keyboard preprocessing. Convert the keys to the internal
  438.  * character set.
  439.  */
  440. getkey()
  441. {
  442.         register int    c;
  443.  
  444.         c = (*term.t_getchar)();
  445.  
  446. #if RAINBOW
  447.  
  448.         if (c & Function_Key)
  449.                 {
  450.                 int i;
  451.  
  452.                 for (i = 0; i < lk_map_size; i++)
  453.                         if (c == lk_map[i][0])
  454.                                 return lk_map[i][1];
  455.                 }
  456.         else if (c == Shift + 015) return CTRL | 'J';
  457.         else if (c == Shift + 0x7F) return META | 0x7F;
  458. #endif
  459.  
  460.         if (c == METACH) {                      /* Apply M- prefix      */
  461.                 c = getctl();
  462.                 return (META | c);
  463.         }
  464.  
  465.         if (c>=0x00 && c<=0x1F)                 /* C0 control -> C-     */
  466.                 c = CTRL | (c+'@');
  467.         return (c);
  468. }
  469.  
  470. /*
  471.  * Get a key.
  472.  * Apply control modifications to the read key.
  473.  */
  474. getctl()
  475. {
  476.         register int    c;
  477.  
  478.         c = (*term.t_getchar)();
  479.         if (c>='a' && c<='z')                   /* Force to upper       */
  480.                 c -= 0x20;
  481.         if (c>=0x00 && c<=0x1F)                 /* C0 control -> C-     */
  482.                 c = CTRL | (c+'@');
  483.         return (c);
  484. }
  485.  
  486. /*
  487.  * Fancy quit command, as implemented by Norm. If the current buffer has
  488.  * changed do a write current buffer and exit emacs, otherwise simply exit.
  489.  */
  490. quickexit(f, n)
  491. {
  492.         if ((curbp->b_flag&BFCHG) != 0          /* Changed.             */
  493.         && (curbp->b_flag&BFTEMP) == 0)         /* Real.                */
  494.                 filesave(f, n);
  495.         quit(f, n);                             /* conditionally quit   */
  496. }
  497.  
  498. /*
  499.  * Quit command. If an argument, always quit. Otherwise confirm if a buffer
  500.  * has been changed and not written out. Normally bound to "C-X C-C".
  501.  */
  502. quit(f, n)
  503. {
  504.         register int    s;
  505.  
  506.         if (f != FALSE                          /* Argument forces it.  */
  507.         || anycb() == FALSE                     /* All buffers clean.   */
  508.         || (s=mlyesno("Quit")) == TRUE) {       /* User says it's OK.   */
  509.                 vttidy();
  510.                 exit(GOOD);
  511.         }
  512.         return (s);
  513. }
  514.  
  515. /*
  516.  * Begin a keyboard macro.
  517.  * Error if not at the top level in keyboard processing. Set up variables and
  518.  * return.
  519.  */
  520. ctlxlp(f, n)
  521. {
  522.         if (kbdmip!=NULL || kbdmop!=NULL) {
  523.                 mlwrite("Not now");
  524.                 return (FALSE);
  525.         }
  526.         mlwrite("[Start macro]");
  527.         kbdmip = &kbdm[0];
  528.         return (TRUE);
  529. }
  530.  
  531. /*
  532.  * End keyboard macro. Check for the same limit conditions as the above
  533.  * routine. Set up the variables and return to the caller.
  534.  */
  535. ctlxrp(f, n)
  536. {
  537.         if (kbdmip == NULL) {
  538.                 mlwrite("Not now");
  539.                 return (FALSE);
  540.         }
  541.         mlwrite("[End macro]");
  542.         kbdmip = NULL;
  543.         return (TRUE);
  544. }
  545.  
  546. /*
  547.  * Execute a macro.
  548.  * The command argument is the number of times to loop. Quit as soon as a
  549.  * command gets an error. Return TRUE if all ok, else FALSE.
  550.  */
  551. ctlxe(f, n)
  552. {
  553.         register int    c;
  554.         register int    af;
  555.         register int    an;
  556.         register int    s;
  557.  
  558.         if (kbdmip!=NULL || kbdmop!=NULL) {
  559.                 mlwrite("Not now");
  560.                 return (FALSE);
  561.         }
  562.         if (n <= 0) 
  563.                 return (TRUE);
  564.         do {
  565.                 kbdmop = &kbdm[0];
  566.                 do {
  567.                         af = FALSE;
  568.                         an = 1;
  569.                         if ((c = *kbdmop++) == (CTRL|'U')) {
  570.                                 af = TRUE;
  571.                                 an = *kbdmop++;
  572.                                 c  = *kbdmop++;
  573.                         }
  574.                         s = TRUE;
  575.                 } while (c!=(CTLX|')') && (s=execute(c, af, an))==TRUE);
  576.                 kbdmop = NULL;
  577.         } while (s==TRUE && --n);
  578.         return (s);
  579. }
  580.  
  581. /*
  582.  * Abort.
  583.  * Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
  584.  * Sometimes called as a routine, to do general aborting of stuff.
  585.  */
  586. ctrlg(f, n)
  587. {
  588.         (*term.t_beep)();
  589.         if (kbdmip != NULL) {
  590.                 kbdm[0] = (CTLX|')');
  591.                 kbdmip  = NULL;
  592.         }
  593.         return (ABORT);
  594. }
  595.  
  596.  
  597.